<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>td{width: 100px}</style>
</head>
<body>
<table border="1">
  <caption>个人信息</caption>
  <tr><td>照片:</td><td id="pic_td"></td></tr>
  <tr><td>姓名:</td><td id="name_td"></td></tr>
  <tr><td>年龄:</td><td id="age_td"></td></tr>
  <tr><td>好友:</td><td id="friends_td"></td></tr>
</table>
<input type="button" value="加载数据" onclick="f()">
<script>
  let nameTd = document.querySelector("#name_td");
  let ageTd = document.querySelector("#age_td");
  let picTd = document.querySelector("#pic_td");
  let friendsTd = document.querySelector("#friends_td");
  function f() {
    //模拟数据是从服务器请求回来的数据
    let person = {name:"传奇哥",age:18,imgUrl:"../b.jpg",
      friends:["孙尚香","武则天","貂蝉"]};
    //对象里面的数据显示到页面中
    nameTd.innerText = person.name;
    ageTd.innerText = person.age;
    //图片
    let img = document.createElement("img");
    img.src = person.imgUrl;
    img.width=100;
    picTd.append(img);
    //好友
    let ul = document.createElement("ul");
    for (let friend of person.friends) {
      let li = document.createElement("li");
      li.innerText = friend;
      ul.append(li);
    }
    friendsTd.append(ul);

  }
</script>
</body>
</html>